﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace OneMG.Phoenix.Cache
{
    public class HashTableProvider : ICacheProvider
    {
        private static readonly HashTableProvider instance = new HashTableProvider();

        private static Hashtable _cache = new Hashtable();

        private HashTableProvider()
        {

        }

        public static HashTableProvider GetInstance()
        {
            return instance;
        }

        #region ICacheProvider 成员

        public bool Contains(string key)
        {
            return _cache.Contains(key);
        }

        public object Get(string key)
        {
            return _cache[key];
        }

        public System.Collections.IDictionary Gets(string[] keys)
        {
            return null;
        }

        public void Add(string key, object value)
        {
            if (_cache.Contains(key))
            {
                Remove(key);
            }
            _cache.Add(key, value);
        }

        public void Add(string key, object value, DateTime expr)
        {
            if (_cache.Contains(key))
            {
                Remove(key);
            }
            _cache.Add(key, value);
        }

        public void Remove(string key)
        {
            _cache.Remove(key);
        }

        public void Clear()
        {
            _cache.Clear();
        }

        #endregion
    }
}
